﻿using System;
using System.Collections.Generic;
using System.Text;

namespace RayTrace
{
    public class Lambertian:Material
    {
        private Vector3D albedo; //漫反射系数
        public Lambertian(Vector3D albedo)
        {
            this.Albedo = albedo;
        }
        internal Vector3D Albedo { get => albedo; set => albedo = value; }
        public override bool Scatter(Ray rIn, HitRecord rec, ref Vector3D attenuation, ref Ray scattered)
        {
            Vector3D target = rec.P + rec.Normal + Form1.RandomInUnitSphere();
            Point3D p = new Point3D();
            p.X = rec.P.X;
            p.Y = rec.P.Y;
            p.Z = rec.P.Z;
            scattered = new Ray(p, target - rec.P);
            attenuation = albedo;
            return true;
        }
    }
}
